import { ref } from "vue";
import { defineStore } from "pinia";
import { getLocalToken, removeLocalToken, setLocalToken } from "@/utils/auth";

export const useUserStore =defineStore('user', ()=>{
  const token=ref(getLocalToken()||'')

  const setToken=(val:string)=>{
    token.value=val
    setLocalToken(val)
  }
  const clearToken=()=>{
    token.value=''
    removeLocalToken()
  }
  return{
    token,
    setToken,
    clearToken
  }
})
